package com.visionblue.business.ship.page.orders

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.visionblue.business.ship.base.BaseViewModel
import com.visionblue.business.ship.base.ViewState
import com.visionblue.business.ship.model.bean.response.*
import kotlinx.coroutines.launch

/**
 * @author: xlh
 * @date: 2020-06-08 8:03 AM
 * @desc:
 */
class OrderViewModel(
    private val orderRepository: OrderRepository
) : BaseViewModel() {
    val orderReceiveListResult = MutableLiveData<ViewState<ListBean<OrdersReceiveInfo>>>()
    val orderApplyListResult = MutableLiveData<ViewState<ListBean<OrdersApplyInfo>>>()
    val orderApplyDetailResult = MutableLiveData<ViewState<OrderApplyDetailsInfo>>()
    /**
     * 获取接收联单列表
     */
    fun getOrdersReceiveList(page: Int) {
        viewModelScope.launch {
            checkState(orderReceiveListResult, orderRepository.getOrdersReceiveList(page))
        }
    }

    /**
     * 获取申报单列表
     */
    fun getOrdersApplyList(page: Int) {
        viewModelScope.launch {
            checkState(orderApplyListResult, orderRepository.getOrdersApplyList(page))
        }
    }

    /**
     * 申报单详情页
     */
    fun getOrderApplyDetails(id:String){
        viewModelScope.launch {
            checkState(orderApplyDetailResult,orderRepository.getApplyInfoDetail(id))
        }
    }

}